import { reqCategoryData } from '@/api/category'

Page({
  // 页面的初始数据
  data: {
    categoryList: [],
    activeIndex: 0
  },

  onLoad: function () {
    this.getCategoryData()
  },

  updateActive(event) {
    const { index } = event.currentTarget.dataset

    this.setData({
      activeIndex: index
    })
  },

  async getCategoryData() {
    const res = await reqCategoryData()

    if (res.code === 200) {
      this.setData({
        categoryList: res.data
      })
    }
  }
})
